package com.example.service.impl;

import com.example.mapper.goodproductQuestionlistMapp;
import com.example.pojo.fixtureTechConditionPojo;
import com.example.pojo.goodproductQuestionlistPojo;
import com.example.service.goodproductQuestionlistService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;
import java.util.UUID;

/**
 * ClassName:goodproductQuestionlistImpl
 * Package:com.example.service.impl
 * Description:
 *
 * @Author：牧星苑
 * @Create 2025/7/4 14:12
 * @Version 1.0
 */
@Service
public class goodproductQuestionlistImpl implements goodproductQuestionlistService {
    @Autowired
    private goodproductQuestionlistMapp goodproductQuestionlistMapp;
    //向数据库中写入问题清单，写入数据
    public void insertOne(goodproductQuestionlistPojo question){
        //生成一段低代码格式的id
        UUID uuid = UUID.randomUUID();
        String uuidStr = uuid.toString().replace("-", "");
        question.setId(uuidStr);
        //定义创建时间生成规则
        question.setCreate_time(LocalDateTime.now());
        //定义修改时间生成规则
        question.setUpdate_time(LocalDateTime.now());
        goodproductQuestionlistMapp.insertOne(question);
    }

    //查询所有问题清单记录
    public List<goodproductQuestionlistPojo> queryAll(){
        //调用goodproductQuestionlistMapp.queryAll()方法，将查询结果存储在pojoList变量中
        List<goodproductQuestionlistPojo> pojoList = goodproductQuestionlistMapp.queryAll();
        //直接返回从Mapper获取的结果列表
        return pojoList;
    }

    //第一步，需要先把原始数据拿出来，去问题清单中找到原始数据
    public goodproductQuestionlistPojo selectById(String id) {
        goodproductQuestionlistPojo pojo=goodproductQuestionlistMapp.selectById(id);
        return pojo;
    }

    //第二步：修改问题清单
    public void editOneById(goodproductQuestionlistPojo pojo){
        //定义修改时间生成规则
        pojo.setUpdate_time(LocalDateTime.now());
        //调用 Mapper 编辑数据
        goodproductQuestionlistMapp.editOneByIdUse(pojo);
    }
}
